package com.ruoyi.web.controller.lynhgl;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.lynhgl.domain.TbLynhglLysyl;
import com.ruoyi.lynhgl.service.ITbLynhglLysylService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 楼宇使用量Controller
 * 
 * @author hc
 * @date 2023-11-10
 */
@RestController
@RequestMapping("/lynhgl/lysyl")
public class TbLynhglLysylController extends BaseController
{
    @Autowired
    private ITbLynhglLysylService tbLynhglLysylService;

    /**
     * 查询楼宇使用量列表
     */
    @PreAuthorize("@ss.hasPermi('lynhgl:lysyl:list')")
    @GetMapping("/list")
    public TableDataInfo list(TbLynhglLysyl tbLynhglLysyl)
    {
        startPage();
        List<TbLynhglLysyl> list = tbLynhglLysylService.selectTbLynhglLysylList(tbLynhglLysyl);
        return getDataTable(list);
    }

    /**
     * 导出楼宇使用量列表
     */
    @PreAuthorize("@ss.hasPermi('lynhgl:lysyl:export')")
    @Log(title = "楼宇使用量", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, TbLynhglLysyl tbLynhglLysyl)
    {
        List<TbLynhglLysyl> list = tbLynhglLysylService.selectTbLynhglLysylList(tbLynhglLysyl);
        ExcelUtil<TbLynhglLysyl> util = new ExcelUtil<TbLynhglLysyl>(TbLynhglLysyl.class);
        util.exportExcel(response, list, "楼宇使用量数据");
    }

    /**
     * 获取楼宇使用量详细信息
     */
    @PreAuthorize("@ss.hasPermi('lynhgl:lysyl:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(tbLynhglLysylService.selectTbLynhglLysylById(id));
    }

    /**
     * 新增楼宇使用量
     */
    @PreAuthorize("@ss.hasPermi('lynhgl:lysyl:add')")
    @Log(title = "楼宇使用量", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody TbLynhglLysyl tbLynhglLysyl)
    {
        return toAjax(tbLynhglLysylService.insertTbLynhglLysyl(tbLynhglLysyl));
    }

    /**
     * 修改楼宇使用量
     */
    @PreAuthorize("@ss.hasPermi('lynhgl:lysyl:edit')")
    @Log(title = "楼宇使用量", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody TbLynhglLysyl tbLynhglLysyl)
    {
        return toAjax(tbLynhglLysylService.updateTbLynhglLysyl(tbLynhglLysyl));
    }

    /**
     * 删除楼宇使用量
     */
    @PreAuthorize("@ss.hasPermi('lynhgl:lysyl:remove')")
    @Log(title = "楼宇使用量", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(tbLynhglLysylService.deleteTbLynhglLysylByIds(ids));
    }
}
